package main.gui;

import static javax.swing.UIManager.*;

import java.awt.GridLayout;
import java.awt.LayoutManager;

import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JScrollPane;

import main.gui.action.ExcludeAction;
import main.gui.action.LoadAction;
import main.gui.action.SaveAction;

public class MainGui {

  public static void main(String[] args) {
    try {
      setLookAndFeel(getSystemLookAndFeelClassName());
    }
    catch (Exception e) {
    }

    final App app = new App();
    JFrame window = new JFrame();
    LayoutManager manager = new GridLayout(1, 2, 5, 5);
    window.setLayout(manager);
    window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    window.setSize(500, 700);
    window.add(new JScrollPane(app.getCurrentView()));
    window.add(new JScrollPane(app.getExcludeView()));

    window.setJMenuBar(createMenu(app));
    window.setLocationRelativeTo(null);
    window.setVisible(true);
  }

  public static JMenuBar createMenu(App app) {
    JMenuBar menuBar = new JMenuBar();

    JMenu menu = new JMenu("load / save");
    menuBar.add(menu);

    JMenuItem menuItem = new JMenuItem();
    menuItem.setAction(new LoadAction(app));
    menuItem.setText("load from...");
    menu.add(menuItem);

    JMenuItem exclItem = new JMenuItem();
    exclItem.setAction(new ExcludeAction(app));
    exclItem.setText("load exclude file...");
    menu.add(exclItem);

    JMenuItem saveItem = new JMenuItem();
    saveItem.setAction(new SaveAction(app));
    saveItem.setText("save to...");
    menu.add(saveItem);

    return menuBar;
  }
}
